<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 性感周周
  Date: 2021/12/3
  Time: 9:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="js/jquery-1.9.1.min.js"></script>
    <script src="js/fileupload.js"></script>
    <script src="My97DatePicker/WdatePicker.js"></script>
    <script src="bootstrap-4.6.0-dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="bootstrap-4.6.0-dist/css/bootstrap.min.css">
</head>
<body>
    <div class="row">
        <div class="col-sm-2">
            <jsp:include page="/layout/left1.jsp"></jsp:include>
        </div>
        <div class="col-sm-10">
            <form >
                收货单号 :<input type="type" name="shouhuoid" id="shouhuoid" readonly value="${param.snow!=""?param.snow:snow}">
                收货日期 :<input type="type" name="shouhuodate" onclick="WdatePicker()"> <br>
                制单人工号:  <input type="type" name="uid" value="${user.uid}">
                制单人:  <input type="type" name="uname" value="${user.uname}">
                制单时间:  <input type="type" name="zddate" onclick="WdatePicker()" ><br>
                附件: <input type="file" name="photo">
                备注: <input type="text" name="beizhu"> <br>
            </form>
            <input type="button" id="upd" value="收货">
            <!-- Button trigger modal -->
            <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
               添加
            </button>

            <table id="ta" class="table table-primary table-hover table-striped">
                <tr>
                    <td>编号</td>
                    <td>仓库编号</td>
                    <td>仓库名称</td>
                    <td>库区</td>
                    <td>仓位</td>
                    <td>物料编号</td>
                    <td>物料名称</td>
                    <td>市场价</td>
                    <td>数量</td>
                    <td>金额</td>
                </tr>
            </table>


            <!-- Modal -->
            <div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">&times;</span>
                            </button>
                        </div>
                        <div class="modal-body">
                            <form action="addshmx.do" method="post">
                                编号: <input type="text" name="snow" id="snow" readonly value="${param.snow!=""?param.snow:snow}"><br>
                                仓库编号: <input type="text" name="ckid"><br>
                                仓库名称: <input type="text" name="ckname"><br>
                                库区: <input type="text" name="kuqu"><br>
                                仓位: <input type="text" name="cangwei"><br>
                                物料编号: <input type="text" name="wid"><br>
                                物料名称: <input type="text" name="wname"><br>
                                市场价: <input type="text" name="price"><br>
                                数量: <input type="text" name="num"><br>
                                <input type="submit" value="添加">
                            </form>
                        </div>
                       <%-- <div class="modal-footer">
                            <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                            <button type="button" class="btn btn-primary">Save changes</button>
                        </div>--%>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
<script>
    $(function () {
        if($("#shouhuoid").val()==""){
            $.ajax({
                url:"getsnow.do",
                dataType:"text",
                type:"post",
                success:function (a) {
                    $("#shouhuoid").val(a)
                    $("#snow").val(a)
                }
            })
        }

        $.post(
            "findshmx.do",
            {"snowid1":$("#shouhuoid").val()},
            function (a) {
                for (let i in a) {
                    $("#ta").append(
                        " <tr>" +
                        "                    <td>"+a[i].snow+"</td>" +
                        "                    <td>"+a[i].ckid+"</td>" +
                        "                    <td>"+a[i].ckname+"</td>" +
                        "                    <td>"+a[i].kuqu+"</td>" +
                        "                    <td>"+a[i].cangwei+"</td>" +
                        "                    <td>"+a[i].wid+"</td>" +
                        "                    <td>"+a[i].wname+"</td>" +
                        "                    <td>"+a[i].price+"</td>" +
                        "                    <td>"+a[i].num+"</td>" +
                        "                    <td>"+a[i].prices+"</td>" +
                        "                </tr>"
                    )
                }
            }
        )
    })
    $("#upd").click(function () {
        var formData=new FormData($("form")[0]);
        $.ajax({
            url:"updshouhuo.do",
            data:formData,
            dataType: "json",
            type:"post",
            success:function (a) {
                if(a>0){
                    location="list.do";
                }
            },processData: false,
            contentType:false,
        })
    })
</script>
</html>
